﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace csis.ImmediatorClasses
{
	/// <summary>
	/// Represents a temporarily created file.
	/// </summary>
	public class TemporaryFile : IDisposable
	{
		public TemporaryFile()
		{
			this.FileName = Path.GetTempFileName();
		}

		~TemporaryFile()
		{
			this.Dispose();
		}

		public string FileName { get; private set; }

		public void Dispose()
		{
			if (this.FileName == null)
			{
				return;
			}
			try
			{
				GC.SuppressFinalize(this);
				File.Delete(this.FileName);
				this.FileName = null;
			}
			catch
			{
			}
		}
	}
}
